package com.controller;

import com.feign.TestFeign;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.aspectj.weaver.ast.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/6/13 21:02
 * @since JDK 1.8
 */
@RestController
public class TestController {

    @Autowired
    TestFeign client;

    /**
     * 服务熔断
     * @return
     */
    @HystrixCommand(fallbackMethod = "rpcV3Hystix")
    @RequestMapping("/hello1")
    public String hello1() {
        return client.hello();
    }

    @RequestMapping("/hello")
    public String hello() {
        return client.hello();
    }

    @RequestMapping("/order/create")
    public String createOrder() {
        System.out.println("进入consumer请求");
        return client.hello();
    }

    /**
     * 方法的参数类型，和返回值的类型必须和远程调用的方法保持相同
     * @return
     */
    public String rpcV3Hystix() {
        return "服务正在维护中";
    }

}
